提示層級架構:從指令到邏輯
提示技術已從簡單的指令式輸入,演進為複雜的推理架構,用以引導模型內部的處理路徑。
核心概念
- 零樣本提示(Zero-shot Prompting): 在不提供任何範例的情況下,僅提供任務描述(例如:「將這段翻譯成法語」)。
- 少樣本提示(Few-shot Prompting): 利用「示範」(輸入-輸出對)來定義標籤空間與期望的格式。
- 鏈式思考(Chain-of-Thought, CoT): 一種促使模型產出中間推理步驟的提示技巧。
- 突現特性: 複雜的推理並非明確編程,而是在參數量通常超過 100 億的模型中「突現」出來。
推理模式的轉變
- 指令遵循:直接將輸入映射至輸出。
- 上下文學習: 從提供的範例中學習模式(少樣本提示)。
- 邏輯分解: 將問題拆解為連續的步驟(鏈式思考)。
- 過程監督: 重視「思考」步驟的準確性,而非僅關注最終答案(如 OpenAI o1 所見)。
關鍵洞察
在少樣本情境中,模型表現高度依賴於標籤分佈與示範的相關性,而不僅僅取決於範例數量。
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
Question 1
Which method relies on providing "demonstrations" to guide the model?
Question 2
True or False: Chain-of-Thought reasoning is a capability found in almost all AI models regardless of size.
Challenge: Optimizing Logic Puzzles
Scenario: Optimize a prompt for a model that is struggling with a logic puzzle.
You are using an LLM to solve the following puzzle: "A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost?"
Currently, you are passing the prompt exactly as written above, and the model incorrectly answers "$0.10".
Currently, you are passing the prompt exactly as written above, and the model incorrectly answers "$0.10".
Task 1
Identify if the current prompt is Zero-shot or Few-shot.
Solution:
The current prompt is Zero-shot because it provides the task description without any prior examples or demonstrations of similar solved puzzles.
The current prompt is Zero-shot because it provides the task description without any prior examples or demonstrations of similar solved puzzles.
Task 2
Inject the Zero-shot CoT trigger phrase to improve reasoning accuracy. Rewrite the prompt.
Solution:
"A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost? Let's think step by step:"
"A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost? Let's think step by step:"